import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import 'package:demo/views/base/base_controller.dart';
import 'package:demo/tools/tools_sqlite.dart';
import 'package:demo/tools/tools_storage.dart';
import 'package:demo/component/component_contact.dart';

class GroupKickedController extends BaseController {
  String userId = ToolsStorage().local().userId;
  // 成员列表
  List<ContactModel> dataList = [];
  // 选中列表
  List<String> selectList = [];
  // 成员列表
  void getList() async {
    // 好友列表
    List<ChatFriend> friendList = await ToolsSqlite().friend.getList();
    // 转换
    for (var friend in friendList) {
      if (friend.userId == userId) {
        continue;
      }
      // 组装
      ContactModel data = ContactModel(
        userId: friend.userId,
        nickname: friend.nickname,
        portrait: friend.portrait,
        remark: friend.nickname,
        extend: friend.userNo,
      );
      dataList.add(data);
    }
    update();
  }

  // 踢人
  Future<void> kicked() async {
    // 提醒
    EasyLoading.showToast('移除成功');
    // 返回
    Get.back();
  }

  @override
  void onInit() {
    super.onInit();
    getList();
  }
}
